/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javauil;

import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JRadioButton;

/**
 *
 * @author Thu
 */
public class HelloMouseListener extends MouseAdapter{//MouseAdapter la 1 class implements cac phuong thuc trong class MouseListener

    //Ctrl + Space de chon phuong thuc can hien thuc 
    @Override
    public void mouseClicked(MouseEvent e) {
        Component[] components=e.getComponent().getParent().getComponents();   //tra ve 1 mang cac components cua component Parent(cha cua component quang ra su kien Bnt1- component JFrame)
        int flag=0;
        for(int i=0;i<components.length;i++)
        {

                    if(((JRadioButton)components[i]).isSelected())
                        if("CorrectAnswer".equals(components[i].getName()))
                         {
                                flag=1;
                                break;
                          }
               
            

        }
        if(flag==1)
            System.out.println("Ket qua dung");
        else
            System.out.println("Ket qua sai");


        
    }




}
